﻿Imports Microsoft.VisualBasic
Imports DataDynamics.ActiveReports.Document
Imports DataDynamics.ActiveReports
Imports DataSet_apa
Imports DataSet_apaTableAdapters
Imports utileria

Public Class reporte
    Inherits DataDynamics.ActiveReports.ActiveReport3
    Dim sSQL As String = "SELECT * FROM ANIMAL "
    Dim sWhere As String
    Dim util As New utileria
    Dim sdsDatos As New DataDynamics.ActiveReports.DataSources.SqlDBDataSource
    Dim variables(8) As String
    Dim sCampos As New FiltroReporteDataTable
    Dim _campos As New FiltroReporteTableAdapter
    Public Sub Variable()
        Me.variables(0) = "Sexo"
        Me.variables(1) = "numero"
        Me.variables(2) = "letra"
        Me.variables(3) = "ano"
        Me.variables(4) = "nombre"
        Me.variables(5) = "hierro"
        Me.variables(6) = "propiedad"
        Me.variables(7) = "fechanac"
        InitializeComponent()
    End Sub

    Public Sub New()
        MyBase.New()
        InitializeComponent()
    End Sub

    Public Sub New(ByVal str As String)
        MyBase.New()
        inicializa()
    End Sub
    Protected Overridable Overloads Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
        End If
        MyBase.Dispose(disposing)
    End Sub

    Private WithEvents Encabezado As DataDynamics.ActiveReports.PageHeader
    Friend WithEvents Detalles As DataDynamics.ActiveReports.Detail
    Private WithEvents PieDePagina As DataDynamics.ActiveReports.PageFooter
    <System.Diagnostics.DebuggerStepThrough()> _
    Private Sub InitializeComponent()
        Me.Encabezado = New DataDynamics.ActiveReports.PageHeader
        Me.Detalles = New DataDynamics.ActiveReports.Detail
        Me.PieDePagina = New DataDynamics.ActiveReports.PageFooter
        Dim lblTitulo As New DataDynamics.ActiveReports.Label
        Dim lblNombre As New DataDynamics.ActiveReports.Label
        'Dim brCodigo As New DataDynamics.ActiveReports.Barcode
        CType(lblTitulo, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(lblNombre, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me, System.ComponentModel.ISupportInitialize).BeginInit()
        sWhere = util.sWhereFiltro(160)
        sSQL += sWhere
        sdsDatos.ConnectionString = ConfigurationManager.ConnectionStrings("GanaderiaConnectionString").ConnectionString
        sdsDatos.SQL = sSQL
        '
        '   ENCABEZADO
        '
        Me.Encabezado.Controls.Add(lblTitulo)
        Me.Encabezado.Height = 1.0!
        Me.Encabezado.Name = "Encabezado"
        '
        '   LBLTITULO
        '
        lblTitulo.Alignment = TextAlignment.Center
        lblTitulo.Height = 0.2!
        lblTitulo.Left = 1.75!
        lblTitulo.Name = "lbltitulo"
        lblTitulo.Text = "SANTAFE DEL CAMPO"
        lblTitulo.Style = "font-weight: bold;"
        lblTitulo.Top = 0.3!
        lblTitulo.Width = 1.8!
        '
        '   DETALLES
        '
        Me.Detalles.Height = 0.3!
        Me.Detalles.Name = "Detalles"
        Me.Detalles.Controls.Add(lblNombre)
        ' Me.Detalles.Controls.Add(brCodigo)
        '
        ' Nombre
        '
        lblNombre.DataField = "= numero + letra + ano"
        lblNombre.Height = 0.2!
        lblNombre.Left = 0.0!
        lblNombre.Name = "lblNombre"
        lblNombre.Top = 0.2!
        lblNombre.Width = 1.5!
        Dim x = 2.0!

        If Not IsNothing(variables) Then
            For I = 0 To variables.Length - 1 Step 1
                Dim label1 As New DataDynamics.ActiveReports.Label
                CType(label1, System.ComponentModel.ISupportInitialize).BeginInit()
                label1.DataField = variables(I)
                label1.Height = 0.2!
                label1.Left = x
                label1.Name = "lbl" & variables(I)
                label1.Top = 0.2!
                label1.Width = 0.6!
                Me.Detalles.Controls.Add(label1)
                x += 0.2!
            Next
        End If



        '
        ' Codigo
        '
        'brCodigo.AutoSize = True
        'brCodigo.BarWidth = 0.2!
        'brCodigo.Style = BarCodeStyle.QRCode
        'brCodigo.DataField = "nombre"
        'brCodigo.Text = "LEPJ850817NL0"
        'brCodigo.Left = 3.0!
        'brCodigo.Height = 0.3!
        'brCodigo.Width = 2.0!
        'brCodigo.Top = 0.2!
        '
        '   PIEDEPAGINA
        '
        Me.PieDePagina.Height = 0.3!
        Me.PieDePagina.Name = "PieDePagina"
        '
        ' REPORTE
        '
        Me.MasterReport = True
        Me.PageSettings.PaperHeight = 11.0!
        Me.PageSettings.PaperWidth = 8.5!
        Me.PageSettings.Margins.Left = 0.2!
        Me.PageSettings.Margins.Right = 0.2!
        Me.DataSource = Me.sdsDatos
        Me.Sections.Add(Encabezado)
        Me.Sections.Add(Detalles)
        Me.Sections.Add(PieDePagina)
        CType(lblNombre, System.ComponentModel.ISupportInitialize).EndInit()
        CType(lblTitulo, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me, System.ComponentModel.ISupportInitialize).EndInit()
    End Sub
    Public Sub inicializa()
        Variable()
        Me.Encabezado = New DataDynamics.ActiveReports.PageHeader
        Me.Detalles = New DataDynamics.ActiveReports.Detail
        Me.PieDePagina = New DataDynamics.ActiveReports.PageFooter
        Dim lblTitulo As New DataDynamics.ActiveReports.Label
        Dim lblNombre As New DataDynamics.ActiveReports.Label
        'Dim brCodigo As New DataDynamics.ActiveReports.Barcode
        CType(lblTitulo, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(lblNombre, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me, System.ComponentModel.ISupportInitialize).BeginInit()
        sWhere = util.sWhereFiltro(28)
        sSQL += sWhere
        sdsDatos.ConnectionString = ConfigurationManager.ConnectionStrings("GanaderiaConnectionString").ConnectionString
        sdsDatos.SQL = sSQL
        '
        '   ENCABEZADO
        '
        Me.Encabezado.Controls.Add(lblTitulo)
        Me.Encabezado.Height = 1.0!
        Me.Encabezado.Name = "Encabezado"
        '
        '   LBLTITULO
        '
        lblTitulo.Alignment = TextAlignment.Center
        lblTitulo.Height = 0.2!
        lblTitulo.Left = 1.75!
        lblTitulo.Name = "lbltitulo"
        lblTitulo.Text = "SANTAFE DEL CAMPO"
        lblTitulo.Style = "font-weight: bold;"
        lblTitulo.Top = 0.3!
        lblTitulo.Width = 1.8!
        '
        '   DETALLES
        '
        Me.Detalles.Height = 0.3!
        Me.Detalles.Name = "Detalles"
        Me.Detalles.Controls.Add(lblNombre)
        ' Me.Detalles.Controls.Add(brCodigo)
        '
        ' Nombre
        '
        lblNombre.DataField = "nombre"
        lblNombre.Height = 0.2!
        lblNombre.Left = 0.0!
        lblNombre.Name = "lblNombre"
        lblNombre.Top = 0.2!
        lblNombre.Width = 1.5!
        Dim x = 2.0!

        If Not IsNothing(variables) Then
            For I = 0 To variables.Length - 1 Step 1
                Dim label1 As New DataDynamics.ActiveReports.Label
                CType(label1, System.ComponentModel.ISupportInitialize).BeginInit()
                label1.DataField = variables(I)
                label1.Height = 0.2!
                label1.Left = x
                label1.Name = "lbl" & variables(I)
                label1.Top = 0.2!
                label1.Width = 0.6!
                Me.Detalles.Controls.Add(label1)
                x += 0.2!
            Next
        End If



        '
        ' Codigo
        '
        'brCodigo.AutoSize = True
        'brCodigo.BarWidth = 0.2!
        'brCodigo.Style = BarCodeStyle.QRCode
        'brCodigo.DataField = "nombre"
        'brCodigo.Text = "LEPJ850817NL0"
        'brCodigo.Left = 3.0!
        'brCodigo.Height = 0.3!
        'brCodigo.Width = 2.0!
        'brCodigo.Top = 0.2!
        '
        '   PIEDEPAGINA
        '
        Me.PieDePagina.Height = 0.3!
        Me.PieDePagina.Name = "PieDePagina"
        '
        ' REPORTE
        '
        Me.MasterReport = True
        Me.PageSettings.PaperHeight = 11.0!
        Me.PageSettings.PaperWidth = 8.5!
        Me.PageSettings.Margins.Left = 0.2!
        Me.PageSettings.Margins.Right = 0.2!
        Me.DataSource = Me.sdsDatos
        Me.Sections.Add(Encabezado)
        Me.Sections.Add(Detalles)
        Me.Sections.Add(PieDePagina)
        CType(lblNombre, System.ComponentModel.ISupportInitialize).EndInit()
        CType(lblTitulo, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me, System.ComponentModel.ISupportInitialize).EndInit()
    End Sub
End Class
